
public class DVD implements Comparable<DVD> {
	
	static final Price BASE_PRICE = new Price(Constants.pricePerDvd);
	
	int id;
	String title;
	int year;
	String directorName;
	int quantity;
	
	public DVD(int id, String title, int year, String directorName)
	{
		this.id = id;
		this.title = title;
		this.year = year;
		this.directorName = directorName;
		quantity = 1;
	}
	
	public DVD(DVD dvd)
	{
		this.id = dvd.id;
		this.title = dvd.title;
		this.year = dvd.year;
		this.directorName = dvd.directorName;
		this.quantity = dvd.quantity;
	}
	
	public int getID()
	{
		return id;
	}
	
	public String getTitle()
	{
		return title;
	}
	
	public int getYear()
	{
		return year;
	}
	
	public String getDirectorName()
	{
		return directorName;
	}
	
	public int getQuantity()
	{
		return quantity;
	}
	
	public void setQuantity(int q)
	{
		quantity = q;
	}
	
	public int compareTo(DVD d)
	{
		if (title.toLowerCase().compareTo(d.title.toLowerCase()) != 0)
			return title.toLowerCase().compareTo(d.title.toLowerCase());
		return year - d.year;
	}
	
	public boolean eqauls(Object o)
	{
		return ((DVD)o).id == id;
	}
	
	public Price getPrice()
	{
		return new Price(BASE_PRICE.getCents() * quantity);
	}
	
	public String toString()
	{
		return "{" +getClass().getName() + '@' + Integer.toHexString(hashCode())
			+ ", id=" + id + ", title=" + title + ", year=" + year + ", directorName=" + directorName
			+ ", quantity=" + quantity + "}";		
	}
}
